package com.yisu.expressway.api.core.service.impl;

import com.yisu.expressway.api.core.mapper.GoodsArchivesMapper;
import com.yisu.expressway.api.core.mapper.GoodsSpecificationMapper;
import com.yisu.expressway.api.core.service.IGoodsInfoService;
import com.yisu.expressway.api.domain.request.GoodsInfoRequest;
import com.yisu.expressway.api.domain.vo.CategoryGoodsVo;
import com.yisu.expressway.api.domain.vo.GoodsDetailVo;
import com.yisu.expressway.ewf.entity.GoodsSpecification;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by xlt on 2017/5/2.
 */
@Service
public class GoodsInfoServiceImpl implements IGoodsInfoService {
    @Resource
    private GoodsArchivesMapper goodsArchivesMapper;
    @Resource
    private GoodsSpecificationMapper goodsSpecificationMapper;
    /**
     * 通過商品編號，商品規格編號，分類編號獲取商品详情
     *
     * @param goodsInfoRequest
     * @return
     */
    @Override
    public GoodsDetailVo getGoodsDetail(GoodsInfoRequest goodsInfoRequest) {
        return goodsArchivesMapper.getGoodsDetailInfo(goodsInfoRequest);
    }

    /**
     * 获取商品规格组名
     *
     * @param goodsInfoRequest
     * @return
     */
    @Override
    public List<String> getSpecificationGroupNameByGoodsNoAndCategoryCode(GoodsInfoRequest goodsInfoRequest) {
        return goodsSpecificationMapper.getSpecificationGroupNameByGoodsNoAndCategoryCode(goodsInfoRequest);
    }

    /**
     * 通过规格主键获取当前规格路径
     *
     * @param specificationNo 规格主键
     * @return
     */
    @Override
    public String selectNodePathByPrimaryKey(Long specificationNo) {
        return goodsSpecificationMapper.selectNodePathByPrimaryKey(specificationNo);
    }

    /**
     * 通过商品分类编号与商品编号获取商品规格列表
     *
     * @param goodsInfoRequest 请求信息
     * @return
     */
    @Override
    public List<GoodsSpecification> getSpecificationListByGoodsNoAndCategoryCode(GoodsInfoRequest goodsInfoRequest) {
        return goodsSpecificationMapper.getSpecificationListByGoodsNoAndCategoryCode(goodsInfoRequest);
    }

    /**
     * 通过分类获取分类推荐商品列表
     *
     * @param goodsInfoRequest 分类编号
     * @return 分类列表
     */
    @Override
    public List<CategoryGoodsVo> getGoodsListByCategoryCode(GoodsInfoRequest goodsInfoRequest) {
        return goodsArchivesMapper.getGoodsListByCategoryCode(goodsInfoRequest);
    }

    /**
     * 通过分类路径获取其下所有分类商品
     *
     * @param goodsInfoRequest 含分类路径信息
     * @return 分类列表
     */
    @Override
    public List<CategoryGoodsVo> getGoodsListByNodePath(GoodsInfoRequest goodsInfoRequest) {
        return goodsArchivesMapper.getGoodsListByNodePath(goodsInfoRequest);
    }

    /**
     * 通过关键字检索商品列表
     *
     * @param goodsInfoRequest 检索关键字信息
     * @return 商品列表
     */
    @Override
    public List<CategoryGoodsVo> getGoodsListByQuery(GoodsInfoRequest goodsInfoRequest) {
        return goodsArchivesMapper.getGoodsListByQuery(goodsInfoRequest);
    }
}
